<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Introduction - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.mail.introduction.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.mail.introduction.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.mail.html">Zend_Mail</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.mail.html">Zend_Mail</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.mail.sending.html">Sending via SMTP</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.mail.introduction" class="section"><div class="info"><h1 class="title">Introduction</h1></div>
    

    <div class="section" id="zend.mail.introduction.getting-started"><div class="info"><h1 class="title">Getting started</h1></div>
        

        <p class="para">
            <span class="classname">Zend_Mail</span> provides generalized functionality to compose and send
            both text and <acronym class="acronym">MIME</acronym>-compliant multipart e-mail messages. Mail can be
            sent with <span class="classname">Zend_Mail</span> via the default
            <span class="classname">Zend_Mail_Transport_Sendmail</span> transport or via
            <span class="classname">Zend_Mail_Transport_Smtp</span>.
        </p>

        <div class="example" id="zend.mail.introduction.example-1"><div class="info"><p><b>Example #1 Simple E-Mail with Zend_Mail</b></p></div>
            

            <div class="example-contents"><p>
                A simple e-mail consists of some recipients, a subject, a body and a sender. To send
                such a mail using <span class="classname">Zend_Mail_Transport_Sendmail</span>, do the
                following:
            </p></div>

            <pre class="programlisting brush: php">
$mail = new Zend_Mail();
$mail-&gt;setBodyText(&#039;This is the text of the mail.&#039;);
$mail-&gt;setFrom(&#039;somebody@example.com&#039;, &#039;Some Sender&#039;);
$mail-&gt;addTo(&#039;somebody_else@example.com&#039;, &#039;Some Recipient&#039;);
$mail-&gt;setSubject(&#039;TestSubject&#039;);
$mail-&gt;send();
</pre>

        </div>

        <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Minimum definitions</b><br /></span>
            

            <p class="para">
                In order to send an e-mail with <span class="classname">Zend_Mail</span> you have to specify
                at least one recipient, a sender (e.g., with  <span class="methodname">setFrom()</span>),
                and a message body (text and/or <acronym class="acronym">HTML</acronym>).
            </p>
        </p></blockquote>

        <p class="para">
            For most mail attributes there are &quot;get&quot; methods to read the information stored in the
            mail object. for further details, please refer to the <acronym class="acronym">API</acronym>
            documentation. A special one is  <span class="methodname">getRecipients()</span>. It returns an
            array with all recipient e-mail addresses that were added prior to the method call.
        </p>

        <p class="para">
            For security reasons, <span class="classname">Zend_Mail</span> filters all header fields to
            prevent header injection with newline (<em class="emphasis">\n</em>) characters.
            Double quotation is changed to single quotation and angle brackets to square brackets in
            the name of sender and recipients. If the marks are in email address, the marks will be
            removed.
        </p>

        <p class="para">
            You also can use most methods of the <span class="classname">Zend_Mail</span> object with a
            convenient fluent interface.
        </p>

        <pre class="programlisting brush: php">
$mail = new Zend_Mail();
$mail-&gt;setBodyText(&#039;This is the text of the mail.&#039;)
    -&gt;setFrom(&#039;somebody@example.com&#039;, &#039;Some Sender&#039;)
    -&gt;addTo(&#039;somebody_else@example.com&#039;, &#039;Some Recipient&#039;)
    -&gt;setSubject(&#039;TestSubject&#039;)
    -&gt;send();
</pre>

    </div>

    <div class="section" id="zend.mail.introduction.sendmail"><div class="info"><h1 class="title">Configuring the default sendmail transport</h1></div>
        

        <p class="para">
            The default transport for a <span class="classname">Zend_Mail</span> instance is
            <span class="classname">Zend_Mail_Transport_Sendmail</span>. It is essentially a wrapper to the
            <acronym class="acronym">PHP</acronym> <a href="http://php.net/mail" class="link external">&raquo;  <span class="methodname">mail()</span></a> function. If you
            wish to pass additional parameters to the <a href="http://php.net/mail" class="link external">&raquo;  <span class="methodname">mail()</span></a> function, simply
            create a new transport instance and pass your parameters to the constructor. The new
            transport instance can then act as the default <span class="classname">Zend_Mail</span>
            transport, or it can be passed to the  <span class="methodname">send()</span> method of
            <span class="classname">Zend_Mail</span>.
        </p>

        <div class="example" id="zend.mail.introduction.sendmail.example-1"><div class="info"><p><b>Example #2 
                Passing additional parameters to the Zend_Mail_Transport_Sendmail transport
            </b></p></div>
            

            <div class="example-contents"><p>
                This example shows how to change the Return-Path of the <a href="http://php.net/mail" class="link external">&raquo;  <span class="methodname">mail()</span></a> function.
            </p></div>

            <pre class="programlisting brush: php">
$tr = new Zend_Mail_Transport_Sendmail(&#039;-freturn_to_me@example.com&#039;);
Zend_Mail::setDefaultTransport($tr);

$mail = new Zend_Mail();
$mail-&gt;setBodyText(&#039;This is the text of the mail.&#039;);
$mail-&gt;setFrom(&#039;somebody@example.com&#039;, &#039;Some Sender&#039;);
$mail-&gt;addTo(&#039;somebody_else@example.com&#039;, &#039;Some Recipient&#039;);
$mail-&gt;setSubject(&#039;TestSubject&#039;);
$mail-&gt;send();
</pre>

        </div>

        <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Safe mode restrictions</b><br /></span>
            

            <p class="para">
                The optional additional parameters will be cause the <a href="http://php.net/mail" class="link external">&raquo;  <span class="methodname">mail()</span></a> function to
                fail if <acronym class="acronym">PHP</acronym> is running in safe mode.
            </p>
        </p></blockquote>

        <div class="warning"><b class="warning">Warning</b><div class="info"><h1 class="title">Sendmail Transport and Windows</h1></div>
            

            <p class="para">
                As the <acronym class="acronym">PHP</acronym> manual states the  <span class="methodname">mail()</span>
                function has different behaviour on Windows and on *nix based systems. Using the
                Sendmail Transport on Windows will not work in combination with
                 <span class="methodname">addBcc()</span>. The  <span class="methodname">mail()</span> function will
                sent to the BCC recipient such that all the other recipients can see him as
                recipient!
            </p>

            <p class="para">
                Therefore if you want to use BCC on a windows server, use the SMTP
                transport for sending!
            </p>
        </div>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.mail.html">Zend_Mail</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.mail.html">Zend_Mail</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.mail.sending.html">Sending via SMTP</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.mail.html">Zend_Mail</a></li>
  <li class="active"><a href="zend.mail.introduction.html">Introduction</a></li>
  <li><a href="zend.mail.sending.html">Sending via SMTP</a></li>
  <li><a href="zend.mail.multiple-emails.html">Sending Multiple Mails per SMTP Connection</a></li>
  <li><a href="zend.mail.different-transports.html">Using Different Transports</a></li>
  <li><a href="zend.mail.html-mails.html">HTML E-Mail</a></li>
  <li><a href="zend.mail.attachments.html">Attachments</a></li>
  <li><a href="zend.mail.adding-recipients.html">Adding Recipients</a></li>
  <li><a href="zend.mail.boundary.html">Controlling the MIME Boundary</a></li>
  <li><a href="zend.mail.additional-headers.html">Additional Headers</a></li>
  <li><a href="zend.mail.character-sets.html">Character Sets</a></li>
  <li><a href="zend.mail.encoding.html">Encoding</a></li>
  <li><a href="zend.mail.smtp-authentication.html">SMTP Authentication</a></li>
  <li><a href="zend.mail.smtp-secure.html">Securing SMTP Transport</a></li>
  <li><a href="zend.mail.read.html">Reading Mail Messages</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>